﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sharp.Migrations;

namespace Budgeter.Migrations
{
    class _005_Create_Table_Entry : SchemaMigration
    {

        public override void Up()
        {
            Add.Table("Budget").WithColumns(
                Column.AutoIncrement("BudgetId").AsPrimaryKey(),
                Column.String("Name"),
                Column.Date("CreatedUtc").NotNull(),
                Column.Int32("ReceiptNumber").NotNull(),
                Column.Int32("IntervalId").NotNull()
            );

            Add.ForeignKey("FK_Interval_Budget")
               .OnColumn("IntervalId")
               .OfTable("Budget")
               .ReferencingColumn("IntervalId")
               .OfTable("Interval")
               .OnDeleteNoAction();
        }

        public override void Down()
        {
            Remove.ForeignKey("FK_Interval_Budget").FromTable("Budget");

            Remove.Table("Budget");
        }
    }
}
